/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2024-07-30 16:05:54
 * @LastEditors: wuzhouhai wzh200x@126.com
 * @LastEditTime: 2024-08-06 18:10:38
 * @FilePath: \dwys_web\assets\script\phoenix\messageHandle\s2cUpdateResources_MessageHandle.ts
 * @Description: s2cUpdateResources 消息处理
 */
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { IMessageHandle } from "../../../../extensions/phoenix-plugin-client/assets/core/interface/IMessageHandle";
import messageManager from "../../../../extensions/phoenix-plugin-client/assets/core/managers/message.manager";
import { GameEvent } from "../../common/event/GameEvent";
import { EnumGameRes } from "../define/gameRes.define";
import { OpcodeApp } from "../define/opcode.define";
import * as proto from "../protoc/ts/proto_app.js";

export default class S2CUpdateResources implements IMessageHandle{
    handleMessage(msgData: any): void {
        let response = msgData as proto.s2c_UpdateResources;
        console.log("S2CUpdateResources", response);
        oops.message.dispatchEvent(GameEvent.UpdateGameRes, EnumGameRes.GameResType_Carrot, response.carrot);
        oops.message.dispatchEvent(GameEvent.UpdateGameRes, EnumGameRes.GameResType_MinCarrot, response.minCarrot);
    }
}

messageManager.registerHandle(OpcodeApp.Opcode_SC_UPDATE_RESOURCES, new S2CUpdateResources());